﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Public;

namespace DAL
{
    public class DanTocDAL
    {
        public static List<DanTocPublic>LoadDanToc()
        {
            var dantoc = Common.db.ExecuteStoreQuery<DanTocPublic>(@"select * from DanToc");
            //int a= dantoc.ToList().Count;
            return dantoc.ToList();

            //List<DanTocPublic> list = new List<DanTocPublic>();
            //var query = from q in Common.db.DanTocs
            //            select q;
            //foreach (var item in query)
            //{
            //    DanTocPublic tg = new DanTocPublic(item.MaDT, item.TenDanToc);
            //    list.Add(tg);
            //}
            //return list;
        }
        public static DanTocPublic GetDanTocByMaDT(int MaDT)
        {
            var dantoc = Common.db.ExecuteStoreQuery<DanTocPublic>(@"select TenDanToc from DanToc where MaDT=" + MaDT);
            return dantoc.FirstOrDefault();
        }
    }
}
